import { request } from "@/utils/service"
import type * as Banner from "./types/banner"

/** 分页查询轮播图列表 */
export function getBannerListApi(params: Banner.BannerQueryParam) {
  return request<Banner.BannerListResponse>({
    url: "/banner/page",
    method: "get",
    params
  })
}

/** 获取轮播图详情 */
export function getBannerDetailApi(bannerId: number) {
  return request<Banner.BannerDetailResponse>({
    url: `/banner/detail/${bannerId}`,
    method: "get"
  })
}

/** 创建轮播图 */
export function createBannerApi(data: Banner.CreateBannerRequest) {
  return request<Banner.CreateBannerResponse>({
    url: "/banner/create",
    method: "post",
    data
  })
}

/** 更新轮播图 */
export function updateBannerApi(data: Banner.UpdateBannerRequest) {
  return request<Banner.UpdateBannerResponse>({
    url: "/banner/update",
    method: "post",
    data
  })
}

/** 删除轮播图 */
export function deleteBannerApi(bannerId: number) {
  return request<Banner.DeleteBannerResponse>({
    url: `/banner/delete/${bannerId}`,
    method: "post"
  })
}

/** 批量删除轮播图 */
export function batchDeleteBannerApi(bannerIds: number[]) {
  return request<Banner.BatchDeleteBannerResponse>({
    url: "/banner/batchDelete",
    method: "post",
    data: bannerIds
  })
}

/** 更新轮播图状态 */
export function updateBannerStatusApi(bannerId: number, status: number) {
  return request<Banner.UpdateBannerStatusResponse>({
    url: `/banner/updateStatus/${bannerId}/${status}`,
    method: "post"
  })
}